$(function(){
    // 切换内容
    var middleP2 = $('.middleP2')
    var m2box = $('.m2box ')
    var m2yc = $('.m2yc')
    middleP2.click(function(){
        middleP2.removeClass("mP2border")
        $(this).addClass('mP2border')
        if(this == middleP2[0]){
            m2yc.css('display','none')
            $(m2yc[0]).css('display','block')
        }else if(this == middleP2[1]){
            m2yc.css('display','none')
            $(m2yc[1]).css('display','block')
        }if(this == middleP2[2]){
            m2yc.css('display','none')
            $(m2yc[2]).css('display','block')
        }
    })

    // 获取导购-最新内容
    $.get('http://localhost:3000/guid/new',function(val){
        console.log(val);
        for (var i = 0; i < 4; i++) {
            for (var ii = 0; ii < 4; ii++) {
    // 添加内容
                var content = $(
                    `<div>
                    <div class="cttbox1 cttDgJx">
                        <div class="cttimg">
                        <img  class="cttimg1" src="${val[ii].img}" >
                        </div>
                        <p class="bgP">${val[ii].text}</p>
                        <div class="cttXia">
                            <div class="cttXi">
                                <img src="../img/xin.png" >3
                                <img src="../img/reply.png" >3
                            </div>
                        </div>
                    </div>
                    <div><img src="../img/listbg.jpg" alt=""></div>
               </div>`
                )
                $(m2box[0]).append(content)
            }
        }
    })
    // 获取导购-最热内容
    $.get('http://localhost:3000/guid/hot',function(val){
    console.log(val);
    // 循环添加内容
    for (var i = 0; i < 4; i++) {
        for (var ii = 4; ii < 8; ii++) {
            var content = $(
                `<div>
                    <div class="cttbox1 cttDgJx">
                        <div class="cttimg">
                        <img  class="cttimg1" src="${val[ii].img}" >
                        </div>
                        <p class="bgP">${val[ii].text}</p>
                        <div class="cttXia">
                            <div class="cttXi">
                                <img src="../img/xin.png" >3
                                <img src="../img/reply.png" >3
                            </div>
                        </div>
                    </div>
                    <div><img src="../img/listbg.jpg" alt=""></div>
               </div>`
            )
            $(m2box[1]).append(content)
        }
    }
    })


})
